<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<style>
.form_field_name {
	display: inline-block;
	width: 60px;
	text-align: left;
}

.form_field_value {
	width: 200px;
}
</style>
<script>

////////console.log('mq');
	$(function() {
		////////console.log('load');
		//webService.initParametersTable();
		$
				.get(
						'getWsConfigList.action?random=' + Math.random(),
						function(data) {
						webService.initParametersTable();
							data = encodeURIComponent(data);
							data = decodeURIComponent(data);
							data = $.parseJSON(data);
							if (true) {
								var columns = [
										{
											field : 'no',
											checkbox : true,
											width : 20
										},
										{
											field : 'methodName',
											title : 'ID',
											width : 150
										},
										{
											field : 'createTime',
											title : '创建时间',
											width : 100
										},
										{
											field : 'updateTime',
											title : '更新时间',
											width : 100
										},
										{
											field : 'createUserid',
											title : '创建人',
											width : 50
										},
										{
											field : 'updateUserid',
											title : '更新人',
											width : 50
										},
										{
											field : 'dispatch.funFullName',
											title : '方法名',
											width : 200
											},
										{
											field : 'dispatch',
											title : '操作',
											width : 100,
											align : 'center',
											formatter : function(value, rec,
													index) {
												var html = '';
												if (value == null)
													return '';
												return html;
											}
										} ];
								$('#ws_config_list_div').datagrid({
									pagination : true,
									rownumbers : true,
									striped : true,
									height : 400,
									singleSelect : true,
									columns : [ columns ],
									toolbar : [ {
										text : '增加',
										iconCls : 'icon-add',
										handler : function() {
											webService.changeToInsertMode();
										}
									}, {
										text : '新增并复制当前项',
										iconCls : 'icon-remove',
										handler : function() {
											webService.changeToInsertModeAndCopyCurrent();
										}
									}, {
										text : '删除',
										iconCls : 'icon-remove',
										handler : function() {
											webService.deleteConfig();
										}
									}, {
										text : '配置',
										iconCls : 'icon-edit'
									} ],
									onSelect : function(rowIndex, rowData) {
										webService.onRowSelected(rowIndex, rowData);
									}
								});
								$('#ws_config_list_div')
										.datagrid('loadData', data);
							}
						})
	});
	
	
	
	var webService = {
		formData : null,
		currentMode : null,
		fieldSourceTypeEnum : [{name:'TEXT', value:'TEXT'},{name:'TEXTAREA',value:'TEXTAREA'},{name:'DB_SELECT',value:'DB_SELECT'},{name:'PASSWORD',value:'PASSWORD'}]
		,
		changeToUpdateMode : function(){
			webService.loadFormData(webService.formData);
			webService.currentMode = 'update';
			$('#ws_save_btn .icon-save').html('保存修改');
		},
		changeToInsertMode : function() {
			$('#ws_config_detail_form :input').each(function() {
				if ($(this).attr('type') == 'checkbox') {
					$(this).attr('checked', false);
				} else {
					$(this).val('');
				}
			});
			webService.changeFunType('sql');
			webService.clearParametersTable();
			webService.currentMode = 'insert';
			$('#ws_save_btn .icon-save').html('保存新增');
		},
		changeToInsertModeAndCopyCurrent : function() {
			if (webService.formData == null) {
				alert('请选中一个待复制项');
				return;
			}
			$('#ws_config_detail_form :input[name="wsConfig.no"]').val('');
			webService.currentMode = 'insert';
			$('#ws_save_btn .icon-save').html('保存新增');
		},
		onRowSelected : function(rowIndex, rowData) {
			webService.formData = {
				wsConfig : rowData
			};
			webService.changeToUpdateMode();
		},
		loadFormData : function(formData) {
			$('#ws_config_detail_form :input').each(function() {
				var name = $(this).attr('name');
				if(name == null || name == undefined) {	
					return false;
				}
				var arr = name.split('.');
				var val = formData;
				for ( var property in arr) {
					if (val == null) {
						break;
					}
					val = val[arr[property]];
				}
				$(this).val(val);
			});
			webService.loadParametersToTable(formData.wsConfig);
			//console.log(formData.wsConfig.dispatch);
			if(formData.wsConfig.dispatch != null && formData.wsConfig.dispatch != undefined)
				webService.changeFunType(formData.wsConfig.dispatch.funType);
		},
		changeFunType : function(type) {
			if(type == 'bussiness') {
				$('#bussiness_setting_fieldset').slideDown();
			 	$('#sql_setting_fieldset').slideUp();
			 }
			 else if(type == 'sql') {
			 	$('#bussiness_setting_fieldset').slideUp();
			 	$('#sql_setting_fieldset').slideDown();
			 }
			 else {
			 	$('#bussiness_setting_fieldset').slideDown();
			 	$('#sql_setting_fieldset').slideDown();
			 }
		},
		save : function() {
			if (webService.currentMode == 'update') {
				webService.update();
			} else if (webService.currentMode == 'insert') {
				webService.insert();
			}
		},
		insert : function() {
			//////console.log('insertBegin');
			var submitData = {};
			$('#ws_config_detail_form :input').each(function() {
				submitData[$(this).attr('name')] = $(this).val();
			});
			webService.loadFromForm(formData, null, submitData);
			webService.loadParametersToSubmitData(submitData);
			////////console.log(submitData);
			$.post('insertWsConfig.action?random=' + Math.random(), submitData, function(
					data) {
				////////console.log('Save success');
				alert('Save Successfully');
				webService.reloadConfigList();
			});
		},
		update : function() {
			//////console.log('insertBegin');
			var submitData = {};
			$('#ws_config_detail_form :input').each(function() {
				submitData[$(this).attr('name')] = $(this).val();
			});
			webService.loadFromForm(webService.formData, null, submitData);
			webService.loadParametersToSubmitData(submitData);
			//console.log(submitData);
			$.post('updateWsConfig.action?random=' + Math.random(), submitData, function(
					data) {
				////////console.log('Save success');
				alert('Save Successfully');
				webService.reloadConfigList();
			});
		
		},
		deleteConfig : function() {
			if (webService.formData == null) {
				alert('请选中一个待删除项');
				return;
			}
			var submitData = {};
			webService.loadFromForm(webService.formData, null, submitData);
			$.post('deleteWsConfig.action?random=' + Math.random(), submitData, function(
					data) {
				////////console.log('Save success');
				alert('Save Successfully');
				webService.reloadConfigList();
			});
		},
		reloadConfigList : function() {
			$
				.get(
						'getWsConfigList.action?random=' + Math.random(),
						function(data) {
							data = encodeURIComponent(data);
							data = decodeURIComponent(data);
							data = $.parseJSON(data);
							$('#ws_config_list_div').datagrid('loadData', data);
							webService.formData = null;
						});
			
		},
		loadFromForm : function(parentObj, parentStr, submitData) {
		
			////////console.log(parentObj);
			if (parentObj == null)
				return;
			for (var prop1 in parentObj) {
				var newStr = null;
				if (parentStr == null || parentStr == '') {
					newStr = prop1;
				} else
					newStr = parentStr + '.' + prop1;
				if (submitData[newStr] == null && !is(parentObj[prop1], 'Object')
						&& parentObj[prop1] != null)
					submitData[newStr] = parentObj[prop1];
				if (is(parentObj[prop1], 'Object') || is(parentObj[prop1], 'Array'))
					loadFromForm(parentObj[prop1], newStr, submitData);
			}
		
		},
		
		testSql : function() {
			//////console.log('testSqlBegin');
			var sql = $('#ws_config_detail_form [name="wsConfig.dispatch.funSql"]').val();
			if(sql == null || sql == undefined || sql == '')
				alert('sql语句不能为空');
			else {
				//var reg = new RegExp('$', 'g');
				//var regResult = sql.match(reg);
				//console.log(regResult);
				var array = sql.split('$');
				var parameters = {};
				var hasParameters = false;
				for(var i=1;i<array.length;i=i+2) {
					parameters[array[i]] = '';
					hasParameters = true;
				}
				//console.log(parameters);
				if(hasParameters)
					webService.sql.generateSqlParameters(parameters);
				else
					webService.sql.submitSqlParameters(hasParameters);
			}
			return;
			var submitData = {};
			$('#ws_config_detail_form :input').each(function() {
				submitData[$(this).attr('name')] = $(this).val();
			});
			////////console.log(submitData);
			$.post('wsTestSql.action?random=' + Math.random(), submitData, function(data) {
				var strData = data;
				strData = encodeURIComponent(strData);
				data = decodeURIComponent(strData);
				data = $.parseJSON(data);
				if (data['error'] == null || data['error'] == undefined) {
					//////console.log(strData);
					$('#result_generator_window').window({
						width : 600,
						height : 400,
						modal : true,
						title : 'Result List'
					});
					$('#result_generator_window').css('display', '');
					resultGenerator.generateResult(data.data, 'sql_list_div');
					$('#sql_json_div').html(strData);
				} else {
					alert(data['error']);
				}
			});
		},
		sql : {
			generateSqlParameters : function(parameters) {
				$('#ws_sql_parameters_window').window({  
    				width:600,  
    				height:400,  
    				modal:true,
    				title:'Need parameters' 
				});
				wsResultGenerator.generateObject(parameters, 'ws_sql_parameters_div');  
			},
			submitSqlParameters : function(hasParameters) {
				var sql = $('#ws_config_detail_form [name="wsConfig.dispatch.funSql"]').val();
				if(hasParameters) {
					$('#ws_sql_parameters_div').propertygrid('acceptChanges');
					var parameters = $('#ws_sql_parameters_div').propertygrid('getData').rows;
					//console.log(parameters);
					
					for(var index in parameters) {
						var value = parameters[index].value;
						if(value == null || value == undefined || value == '') {
							alert('参数不能为空');
							return;
						}
					}
					for(var index in parameters) {
						sql = sql.replace('$' + parameters[index].name + '$', parameters[index].value);
					}
					//console.log(sql);
				}
				var submitData = {};
				$('#ws_config_detail_form :input').each(function() {
					submitData[$(this).attr('name')] = $(this).val();
				});
				submitData['wsConfig.dispatch.funSql'] = sql;
				////////console.log(submitData);
				$.post('wsTestSql.action?random=' + Math.random(), submitData, function(data) {
					var strData = data;
					strData = encodeURIComponent(strData);
					data = decodeURIComponent(strData);
					data = $.parseJSON(data);
					if (data['error'] == null || data['error'] == undefined) {
						//////console.log(strData);
						$('#ws_sql_result_window').window({
							width : 600,
							height : 400,
							modal : true,
							title : 'Result List'
						});
						$('#ws_sql_result_window').css('display', '');
						resultGenerator.generateResult(data.data, 'ws_sql_list_div');
						$('#ws_sql_json_div').html(strData);
					} else {
						alert(data['error']);
					}
				});
			},
			viewSql : function() {
				$('#ws_sql_parameters_div').propertygrid('acceptChanges');
				var parameters = $('#ws_sql_parameters_div').propertygrid('getData').rows;
				//console.log(parameters);
				var sql = $('#ws_config_detail_form [name="wsConfig.dispatch.funSql"]').val();
				for(var index in parameters) {
					sql = sql.replace('$' + parameters[index].name + '$', parameters[index].value);
				}
				$('#ws_sql_viewsql_div').html(sql);
			}
		},
		parameters : {
			insertNewRow : function() {
				$('#ws_parameters_div').datagrid('appendRow', {});
				$('#ws_parameters_div').datagrid('acceptChanges');
				for(var index=0;index<$('#ws_parameters_div').datagrid('getData').total;index++) {
					$('#ws_parameters_div').datagrid('refreshRow', index);
				}
			},
			deleteRow : function() {
				var currentRow = $('#ws_parameters_div').datagrid('getSelected');
				if(currentRow == null) {
					alert('请选择一个删除项');
					return;
				}
				var currentIndex = $('#ws_parameters_div').datagrid('getRowIndex', currentRow);
				$('#ws_parameters_div').datagrid('deleteRow', currentIndex);
				$('#ws_parameters_div').datagrid('acceptChanges');
				for(var index=0;index<$('#ws_parameters_div').datagrid('getData').total;index++) {
					$('#ws_parameters_div').datagrid('refreshRow', index);
				}
			}
		},
		loadParametersToSubmitData : function(submitData) {
			$('#ws_parameters_div').datagrid('acceptChanges');	
			if(submitData != null && submitData != undefined) {
				//submitData['generalWsFields'] = null;
				var parameters = $('#ws_parameters_div').datagrid('getData').rows;
				//submitData['wsFieldList'] = parameters;
				for(var index in parameters) {
					parameters[index]['fieldSequence'] = index;
					for(var property in parameters[index]) {
						if(parameters[index][property] != null && parameters[index][property] != undefined)
							submitData['wsConfig.generalWsFields[' + index + '].' + property ] = parameters[index][property];
					}
						
				}
				//console.log(submitData);
			}
		},
		loadParametersToTable : function(wsConfig) {
			if(wsConfig != null && wsConfig != undefined) {
				$('#ws_parameters_div').datagrid('loadData', wsConfig.generalWsFields);
			}
		
		},
		clearParametersTable : function() {
			$('#ws_parameters_div').datagrid('loadData', []);
		},
		initParametersTable : function() {
			var columns = [
										{
											field : 'no',
											checkbox : true,
											width : 20
										},
										{
											field : 'fieldName',
											title : '名称',
											width : 150,
											editor : {
												type : 'text',
												options : {
													required : true
												}
											}
										},
										{
											field : 'fieldDataType',
											title : '数据类型',
											width : 200,
											editor : {
												type : 'text',
												required : true,
												options : {
													required : true
												}
											}
										},
										{
											field : 'fieldSourceType',
											title : '源类型',
											width : 100,
											editor : {
												type : 'combobox',
												required : true,
												options:{  
                    								valueField:'value',  
                   									textField:'name',  
                   			 						data:webService.fieldSourceTypeEnum,  
                    								required:true  
                								} 
											}
										},
										{
											field : 'fieldSourceConfig',
											title : '源构造',
											width : 200
										},
										{
											field : 'dispatch',
											title : '操作',
											width : 100,
											align : 'center',
											formatter : function(value, rec,
													index) {
												var html = '';
												var total = $('#ws_parameters_div').datagrid('getRows').length;
												if(index == 0 && index != total - 1) {
													html += '<a title="下移" href="javascript:void(0)"><img src="themes/gray/images/spinner_arrow_down.gif" /></a>';
												}
												else if(index == total - 1 && index != 0) {
													html += '<a title="上移" href="javascript:void(0)"><img src="themes/gray/images/spinner_arrow_up.gif" /></a>';
												}
												else if(index != total - 1 && index != 0) {
													html += '<a title="上移" href="javascript:void(0)"><img src="themes/gray/images/spinner_arrow_up.gif" /></a>';
													html += '&nbsp;<a title="下移" href="javascript:void(0)"><img src="themes/gray/images/spinner_arrow_down.gif" /></a>';
												}
												return html;
											}
										} ];
								$('#ws_parameters_div').datagrid({
									pagination : true,
									rownumbers : true,
									striped : true,
									height : 200,
									singleSelect : true,
									columns : [ columns ],
									toolbar : [ {
										text : '增加',
										iconCls : 'icon-add',
										handler : function() {
											webService.parameters.insertNewRow();
											
										}
									}, {
										text : '删除',
										iconCls : 'icon-remove',
										handler : function() {
											webService.parameters.deleteRow();
										}
									}, {
										text : '配置',
										iconCls : 'icon-edit'
									}, {
										text : '保存',
										iconCls : 'icon-save',
										handler : function() {
											//console.log($('#ws_parameters_div').datagrid('getData'));
											$('#ws_parameters_div').datagrid('acceptChanges');
											//console.log($('#ws_parameters_div').datagrid('getData'));
										}
									} ],
									onSelect : function(rowIndex, rowData) {
										//webService.onRowSelected(rowIndex, rowData);
									},
									onBeforeEdit:function(index,row){  
        								row.editing = true;  
        								$('#ws_parameters_div').datagrid('refreshRow', index);  
    								},  
    								onAfterEdit:function(index,row){  
        								row.editing = false;  
        								$('#ws_parameters_div').datagrid('refreshRow', index);  
    								},  
   									onCancelEdit:function(index,row){  
        								row.editing = false;  
        								$('#ws_parameters_div').datagrid('refreshRow', index);  
    								},
    								onDblClickRow:function(index,row){
        								$('#ws_parameters_div').datagrid('beginEdit', index);
    								} 
								});
							}
	
	};
	





</script>
<script>

var wsResponse = {};
	var wsRequest = {};
	$(function(){
		//$('#ws_debug_layout').layout('collapse','west');
		requestWSList();
	})

	function generateData() {
		var credential = {
			userName : 'dmj',
			password : '123'
		}
		var wsConfig = {
			methodName : 'fromService'
		}
		var wsRequest = {
			credential : credential,
			wsConfig : wsConfig
		}
		return wsRequest;

	}
	
	function requestWSList(){
		wsRequest.stageFlag = 'REQUEST_WS_LIST';
		request('WebService/WebService/accessPost?random=' + Math.random(), $
				.toJSON(wsRequest), handleRequestWSList)
	}

	function requestParameters() {
		wsRequest = generateData();
		//console.log(wsRequest);
		wsRequest.wsConfig.methodName = $('#ws_list_div').combobox('getValue');
		//console.log('End');
		wsRequest.stageFlag = 'REQUEST_PARAMETERS';
		request('WebService/WebService/accessPost?random=' + Math.random(), $
				.toJSON(wsRequest), handleRequestParameters)
	}
	
	function requestResult(){
		wsRequest.stageFlag = 'REQUEST_RESULT';
		wsRequest.wsParameters = {};
		$('.field_submit_input').each(function(){
			wsRequest.wsParameters[$(this).attr('name')] = $(this).val();
		})
		request('WebService/WebService/accessPost?random=' + Math.random(), $
				.toJSON(wsRequest), handleRequestResult)
	}
	
	var wsListComboBoxLoaded = false;
	
	function handleRequestWSList(data){
		//console.log('Receive Parameters End');
		data = encodeURIComponent(data);
		data = decodeURIComponent(data);
		//console.log(data);
		wsResponse = $.parseJSON(data);
		if(wsListComboBoxLoaded == false)
			$('#ws_list_div').combobox({onSelect:requestParameters,valueField:'methodName',textField:'methodName',id:'ws_input'}); 
		wsListComboBoxLoaded = true; 
		$('#ws_list_div').combobox('loadData', wsResponse.wsResult.returnData.data);
		$('#ws_list_div').combobox('setValue', null);
		$('#response_stage1_div').html('');
		$('#response_stage2_div').html('');
		$('#generate_list_div').html('');
		$('#return_data_div').html('');
		$('#columns_form_div').html('');
		
		$('#ws_property_div').treegrid('loadData',{total:0,rows:[]});
	}
	
	function handleRequestParameters(data) {
		//console.log('Receive Parameters End');
		data = encodeURIComponent(data);
		data = decodeURIComponent(data);
		//console.log(data);
		wsResponse = $.parseJSON(data);
		wsRequest.wsConfig = wsResponse.wsConfig;
		$('#response_stage1_div').html(data);
		wsFormGenerator.generateForm(wsResponse.wsConfig.generalWsFields,
				'columns_form_div');
		/*$('#ws_property_div').propertygrid({
			showGroup : true
		});
		var propertyArray = propertyFormatter.formatObject(wsResponse.wsConfig);
		$('#ws_property_div').propertygrid('loadData', propertyArray);*/
		var propertyArray = propertyFormatter.formatObjectTree(wsResponse);
		//console.log('PropertyArray');
		//console.log($.toJSON(propertyArray));
		//console.log(propertyArray);
		$('#ws_property_div').treegrid({
			idField:'id',  
    		treeField:'name',  
    		columns:[[  
        		{title:'Name',field:'name',width:180},  
        		{field:'value',title:'Value',width:200,align:'right'}  
    		]]  
		});
		$('#ws_property_div').treegrid('loadData', propertyArray);
		/*for(var index in propertyArray){
			$('#ws_property_div').propertygrid('appendRow', propertyArray[index]);
		}*/

	}
	
	function handleRequestResult(data){
		//console.log('Receive Result End');
		data = encodeURIComponent(data);
		data = decodeURIComponent(data);
		//console.log(data);
		wsResponse = $.parseJSON(data);
		$('#response_stage2_div').html(data);
		$('#return_data_div').html($.toJSON(wsResponse.wsResult.returnData.data));
	}
	
	function generateResult(){
			$('#ws_result_generator_window').window({  
    			width:600,  
    			height:400,  
    			modal:true,
    			title:'Result List' 
			});  
			//wsResultGenerator.generateResult(wsResponse.wsResult.returnData.data, 'ws_result_generator_div');
			wsResultGenerator.generateResultTree(wsResponse.wsResult.returnData.data, 'ws_result_generator_div');
	}

	function request(url, requestData, success) {
		//console.log(success);
		$.post(url, requestData, success, 'text');
	}

	var wsFormGenerator = {
		generateForm : function(columns, containerId) {
			//console.log(columns);
			var html = '<form method="post">';
			for (index in columns) {
				html += '<div><label class="form_field_name">'
						+ columns[index].fieldName + '</label>';
				if(columns[index].fieldSourceType == 'TEXT')		
					html += '<input name="' + columns[index].fieldName + '" class="field_submit_input" type="text" />';
				else if(columns[index].fieldSourceType == 'TEXTAREA')		
					html += '<textarea name="' + columns[index].fieldName + '" class="field_submit_input" type="text"></textarea>';
				else if(columns[index].fieldSourceType == 'PASSWORD'){
					html += '<input type="password" name="' + columns[index].fieldName + '" class="field_submit_input" />';
				}
				else if(columns[index].fieldSourceType == 'DB_SELECT'){
					html += '<select>';
					var sourceData = columns[index].sourceConfig.data;
					for (index1 in sourceData){
						html += '<option>' + sourceData[index1] + '</option>';
					}
					html += '</select>';
				}
				html+= '<span>(' + columns[index].fieldDataType + ')</span><div>';
			}
			html += '</form>';
			$('#' + containerId).html(html);
		}
	}
	
	var wsResultGenerator = {
		generateList : function(data, containerId){
			if(data.length > 0)
			{
				var columns = [];
				var tempData = data[0];
				for(var property in tempData){
					var column = {};
					column.field = property;
					column.title = property;
					column.width = 100;
					columns[columns.length] = column;
				}
				$('#' + containerId).datagrid({
					pagination : true,
    				columns:[columns]  
				}); 
				$('#' + containerId).datagrid('loadData', data); 
			}			
		},
		generateObject : function(data, containerId){
			var propertyArray = propertyFormatter.formatObject(data);
			$('#' + containerId).propertygrid({
				showGroup : true
			});
			$('#' + containerId).propertygrid('loadData', propertyArray);
		},
		generateResult : function(data, containerId){
			if(is(data,'Object')){
				wsResultGenerator.generateObject(data,containerId);
			}
			else if(is(data,'Array')){
				wsResultGenerator.generateList(data,containerId);
			}
			else
				alert('Return Data Invalid');
		},
		generateResultTree : function(data, containerId) {
			var propertyArray = propertyFormatter.formatObjectTree(data);
				$('#' + containerId).treegrid({
					idField:'id',  
    				treeField:'name',  
    				columns:[[  
        				{title:'Name',field:'name',width:180},  
        				{field:'value',title:'Value',width:200,align:'right'}  
    				]]  
			});
			$('#' + containerId).treegrid('loadData', propertyArray);
		}
	};

	var propertyFormatter = {
		formatObject : function(data) {
			var result = {};
			var rows = [];
			for ( var property in data) {
				var row = {};
				row.name = property;
				row.value = data[property];
				row.group = 'Property';
				row.editor = 'text';
				rows[rows.length] = row;
			}
			result.total = rows.length;
			result.rows = rows;
			return result;
		},
		formatObjectTreeLoop : function(data, parentId, rows) {
			for (var property in data) {
				var index = rows.length+1;
				var row = {};		
				row.name = property;
				row.value = data[property];
				if(parentId != 0)
				{
					row._parentId = parentId;
				}
				row.id = index;
				rows[rows.length] = row;
				if(is(data[property],'Object') || is(data[property],'Array'))
					propertyFormatter.formatObjectTreeLoop(data[property],row.id, rows)
				
			}
		},
		formatObjectTree : function(data) {
			var result = {};
			var rows = [];
			propertyFormatter.formatObjectTreeLoop(data, 0, rows);
			result.total = rows.length;
			result.rows = rows;
			return result;
		}
	}
	
	var is = function (obj,type) {
        return (type === "Null" && obj === null) ||
        (type === "Undefined" && obj === void 0 ) ||
        (type === "Number" && isFinite(obj)) ||
         Object.prototype.toString.call(obj).slice(8,-1) == type;
	}
</script>

<div id="ws_tabs" class="easyui-tabs" plain="true" tools="#tab-tools"
	width="100%" height="100%">
	<div title="List" tools="#p-tools" style="padding: 20px;">
		<div id="ws_config_list_div"></div>
		<div style="width: 100%; height: 20"></div>
		<div id="ws_config_detail_div">
			<div class="toolbar">
				<a id="ws_save_btn" href="javascript:void(0)"
					class="easyui-linkbutton l-btn" iconcls="icon-save"
					onclick="javascript:webService.save()">保存</a> <a id="ws_reset_btn"
					href="javascript:void(0)" class="easyui-linkbutton l-btn"
					iconcls="icon-undo">重置</a>
			</div>
			<form id="ws_config_detail_form">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="7" bgcolor="#E8EEF5">&nbsp;</td>
						<td width="24" align="center" bgcolor="#E8EEF5"><img
							src="images/arrow_02.jpg" width="16" height="16">
						</td>
						<td height="35" align="left" bgcolor="#E8EEF5" class="area_Title">
							基本设置</td>
						<td width="112" align="right" bgcolor="#E8EEF5" class="black12">
							<img id="img0" src="images/min.jpg"
							onclick="javascript:turnit('i0','img0');" width="11" height="11">
						</td>
						<td width="10" align="center" bgcolor="#E8EEF5" class="black12">
							&nbsp;</td>
					</tr>
				</table>
				<table width="100%">
					<tr>
						<td class="formTitle">NO</td>
						<td class="formInfo"><input name="wsConfig.no"
							disabled="disabled" />
						</td>
						<td class="formTitle">ID</td>
						<td class="formInfo"><input name="wsConfig.methodName" />
						</td>
					</tr>
					<tr>
						<td class="formTitle">服务端应用代码</td>
						<td class="formInfo"><input name="wsConfig.serverAppCode" />
						</td>
						<td class="formTitle">服务端应用类型</td>
						<td class="formInfo"><input name="wsConfig.serverAppType" />
						</td>
					</tr>
					<tr>
						<td class="formTitle">客户端应用代码</td>
						<td class="formInfo"><input name="wsConfig.clientAppCode" />
						</td>
						<td class="formTitle">客户端应用类型</td>
						<td class="formInfo"><input name="wsConfig.clientAppType" />
						</td>
					</tr>
					<tr>
						<td class="formTitle">描述</td>
						<td class="formInfo" colspan="3"><textarea
								style="width:200px" name="wsConfig.remark"></textarea>
						</td>
					</tr>
					<tr>
						<td class="formTitle"></td>
						<td class="formInfo"></td>
						<td class="formTitle"></td>
						<td class="formInfo"></td>
					</tr>
				</table>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="7" bgcolor="#E8EEF5">&nbsp;</td>
						<td width="24" align="center" bgcolor="#E8EEF5"><img
							src="images/arrow_02.jpg" width="16" height="16">
						</td>
						<td height="35" align="left" bgcolor="#E8EEF5" class="area_Title">
							高级设置</td>
						<td width="112" align="right" bgcolor="#E8EEF5" class="black12">
							<img id="img0" src="images/min.jpg"
							onclick="javascript:turnit('i0','img0');" width="11" height="11">
						</td>
						<td width="10" align="center" bgcolor="#E8EEF5" class="black12">
							&nbsp;</td>
					</tr>

				</table>

				<table width="100%">
					<tr>
						<td class="formTitle">执行类型</td>
						<td class="formInfo" colspan="3"><select
							name="wsConfig.dispatch.funType"
							onchange="webService.changeFunType(this.value)">
								<option value="sql">SQL</option>
								<option value="bussiness">业务方法</option>
								<option value="both" disabled="disabled">SQL &
									Bussiness</option>
						</select>
						</td>
					</tr>
					<tr>
						<td class="formTitle"></td>
						<td class="formInfo"></td>
						<td class="formTitle"></td>
						<td class="formInfo"></td>
					</tr>
				</table>
				<div id="sql_setting_fieldset" class="fieldset flash" align="left"
					style="width: 100%;">
					<span class="legend" style="font: 700 11px Helvetica, sans-serif;">数据库设置</span>
					<div>
						<table width="100%">
							<tr>
								<td class="formTitle">连接字符串</td>
								<td class="formInfo" colspan="3"><textarea
										name="wsConfig.dispatch.connectStr" style="width: 200px"></textarea>

								</td>

							</tr>

							<tr>
								<td class="formTitle">表名称</td>
								<td class="formInfo"><input
									name="wsConfig.dispatch.tableNameEn" />
								</td>
							</tr>

							<tr>
								<td class="formTitle">数据库用户名</td>
								<td class="formInfo"><input
									name="wsConfig.dispatch.databaseUserName" />
								</td>
								<td class="formTitle">数据库密码</td>
								<td class="formInfo"><input
									name="wsConfig.dispatch.databasePassword" type="password" />
								</td>
							</tr>
							<tr>

								<td class="formTitle">SQL语句</td>
								<td class="formInfo" colspan="3"><textarea
										name="wsConfig.dispatch.funSql"
										style="width: 50%; height: 80px"></textarea> <a
									href="javascript:void(0)"
									onclick="webService.testSql();return false;">测试SQL
										</a>
								</td>
							</tr>
						</table>
					</div>
				</div>

				<div id="bussiness_setting_fieldset" class="fieldset flash"
					align="left" style="width: 100%;">
					<span class="legend" style="font: 700 11px Helvetica, sans-serif;">业务方法设置</span>
					<div>
						<table width="100%">
							<tr>
								<td class="formTitle">业务方法类型</td>
								<td class="formInfo" colspan="3"><select
									name="wsConfig.dispatch.funFlag"><option>method</option>
										<option>bean</option>
								</select>
								</td>
							</tr>
							<tr>
								<td class="formTitle">业务方法名称</td>
								<td class="formInfo" colspan="3"><textarea
										name="wsConfig.dispatch.funFullName"
										style="width: 50%; height: 80px"></textarea>
								</td>
							</tr>
							<tr>
								<td class="formTitle"></td>
								<td class="formInfo"></td>
								<td class="formTitle"></td>
								<td class="formInfo"></td>
							</tr>
						</table>
					</div>
				</div>



			</form>
			<form>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="7" bgcolor="#E8EEF5">&nbsp;</td>
						<td width="24" align="center" bgcolor="#E8EEF5"><img
							src="images/arrow_02.jpg" width="16" height="16">
						</td>
						<td height="35" align="left" bgcolor="#E8EEF5" class="area_Title">
							参数设置</td>
						<td width="112" align="right" bgcolor="#E8EEF5" class="black12">
							<img id="img0" src="images/min.jpg"
							onclick="javascript:turnit('i0','img0');" width="11" height="11">
						</td>
						<td width="10" align="center" bgcolor="#E8EEF5" class="black12">
							&nbsp;</td>
					</tr>
				</table>
				<div id="ws_parameters_div"></div>
			</form>
		</div>

	</div>
	<div title="Debug" tools="#p-tools" style="padding: 20px;">
		<div class="easyui-layout" id="ws_debug_layout"
			style="width:900px;height:800px;">
			<div region="center" style="height:800px;">
				<div>
					<div class="panel" style="display: block; width: 500px;">
						<div id="p" class="easyui-panel panel-body"
							style="width: 478px; height: 152px; padding: 10px;"
							title="Web Service" collapsible="true">
							<div style="display:inline-block">
								<div>Please Select a WebService</div>
								<div style="height:5px;"></div>
								<div id="ws_list_div"></div>
								<div title="刷新">
									<a href="javascript:void(0)" onclick="requestWSList()">刷新</a>
								</div>

							</div>
						</div>
					</div>
				</div>
				<div>
					<div class="panel" style="display: block; width: 500px;">
						<div id="p" class="easyui-panel panel-body"
							style="width: 478px; height: 152px; padding: 10px;"
							title="Parameters String" collapsible="true">
							<div id="response_stage1_div"></div>
						</div>
					</div>
				</div>
				<div>
					<div class="panel" style="display: block; width: 500px;">
						<div id="p" class="easyui-panel panel-body"
							style="width: 478px; height: 152px; padding: 10px;"
							title="Request Form" collapsible="true">
							<div id="columns_form_div"></div>
							<div id="columns_send_div" visible="true">
								<a href="javascript:requestResult()"
									class="easyui-linkbutton l-btn" iconcls="icon-ok">Send</a>
							</div>
						</div>
					</div>
				</div>
				<div>
					<div class="panel" style="display: block; width: 500px;">
						<div id="p" class="easyui-panel panel-body"
							style="width: 478px; height: 152px; padding: 10px;"
							title="Response Stage 2" collapsible="true">
							<div id="response_stage2_div"></div>
						</div>
					</div>
				</div>
				<div>
					<div class="panel" style="display: block; width: 500px;">
						<div id="p" class="easyui-panel panel-body"
							style="width: 478px; height: 152px; padding: 10px;"
							title="Return Data" collapsible="true">
							<div>
								<a href="javascript:generateResult()"
									class="easyui-linkbutton l-btn" iconcls="icon-ok">Generate
									Visual Element</a>
							</div>
							<div id="generate_list_div"></div>
							<div id="return_data_div"></div>
							<div id='result_generator_window'>
								<div id="result_generator_div"></div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div region="east" style="width:400px;height:200px;" collapse="true"
				title="Property Panel">
				<div id="ws_property_div"></div>
			</div>
		</div>
		<div id='ws_result_generator_window'>
			<div id='ws_result_generator_div'></div>
		</div>
		<div id='ws_sql_parameters_window'>
			<div class="toolbar"
				style="margin-top: 10px;margin-left:20px;margin-bottom:10px;">
				<a id="ws_testsql_submit_btn" href="javascript:void(0)"
					class="easyui-linkbutton l-btn" iconcls="icon-save"
					onclick="javascript:webService.sql.submitSqlParameters(true)">提交</a>
				<a id="ws_testsql_viewsql_btn" href="javascript:void(0)"
					class="easyui-linkbutton l-btn" iconcls="icon-view"
					onclick="javascript:webService.sql.viewSql()">查看SQL</a>
			</div>
			<div id="ws_sql_parameters_div"></div>
			<div style="height:10px;width:100%"></div>
			<div id="ws_sql_viewsql_div"
				style="margin-left:30px; margin-right:30px"></div>
		</div>
		<div id='ws_sql_result_window' style="display:none">
			<div id="ws_sql_result_tabs" class="easyui-tabs" tools="#tab-tools"
				width="100%" height="100%">
				<div id="ws_sql_list_div" title="列表" tools="#p-tools"
					style="padding: 20px;"></div>
				<div id="ws_sql_json_div" title=JSON " tools="#p-tools"
					style="padding: 20px;"></div>

			</div>
		</div>


	</div>

</div>
